{include file="common/header"}
<!-- 编辑器 -->
<script charset="utf-8" src="/admin_static/library/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/admin_static/library/kindeditor/lang/zh-CN.js"></script>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                   <div class="ibox-title">
                        <h5>菜单编辑</h5>
                        <span class="label label-primary pull-right label-primary-cust">
                            <a href="javascript:history.back(-1);" class="fa-lg-cust-a" title="返回上一页">
                                <i class="fa fa-arrow-left fa-lg-cust" aria-hidden="true"></i>
                            </a>
                        </span> 
                    </div>
                    <div class="ibox-content">
                        <div class="alert alert-danger">
                            <b>警告：</b>该功能的操作必须和后台开发人员沟通后方可操作
                        </div>
                        <form class="form-horizontal m-t" id="partner" enctype="multipart/form-data">
                            <input type="hidden" name="menu_id" value="<?php echo $self_menu['menu_id']; ?>">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单名称：</label>
                                <div class="col-sm-8">
                                    <input name="menu_name" type="text" value="<?php echo $self_menu['menu_name']; ?>" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">一级菜单：</label>
                                <div class="col-sm-8">
                                    <select <?php echo $child_menu>0?'disabled="disabled"':''; ?> class="input-sm form-control input-s-sm inline" name="pid" style="width:150px;height: 33px;">
                                        <option value="0">请选择</option>
                                        <?php foreach ($first_menu as $key => $value): ?>
                                        <option <?php echo $value['menu_id']==$self_menu['pid']?'selected="selected"':''; ?> value="<?php echo $value['menu_id'] ?>"><?php echo $value['menu_name'] ?></option>
                                        <?php endforeach ?>
                                    </select>
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 不选择一级菜单，则当前菜单为一级菜单，有子菜单时不可编辑</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单地址：</label>
                                <div class="col-sm-8">
                                    <input <?php echo $child_menu>0?'disabled="disabled"':''; ?> name="menu_url" type="text" class="form-control" value="<?php echo $self_menu['menu_url']; ?>" required="" aria-required="true">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 如：/Admin/Index/index，有子菜单时不可编辑</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单图标：</label>
                                <div class="col-sm-8">
                                    <input name="ico" type="text" value="<?php echo $self_menu['ico']; ?>" class="form-control" required="" aria-required="true">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 如：icon-home，只取 home。网址：http://www.bootcss.com/p/font-awesome/</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">菜单排序：</label>
                                <div class="col-sm-8">
                                    <input name="seq" min="0" value="<?php echo $self_menu['seq']; ?>" max="99" type="text" class="form-control" required="" aria-required="true" style="width:80px" oninput="if(value.length>2)value=value.slice(0,2)" onkeyup="value=value.replace(/[^\d]/g,'')">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 输入0~99，数越大越靠前</span>
                                </div>

                            </div>
                            <div class="form-group form-group-bottom">
                                <div class="col-sm-2 col-sm-offset-3">
                                    <p class="btn btn-primary" onclick="submitAdd();">确定修改</p>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            
            </div>
           
        </div>
    </div>
</body>
{include file="common/footer"}
<script>
    //按钮样式
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});

    //添加会员
    function submitAdd(){
        $.ajax({
            url: "/Admin/Menu/menu_edit",
            data:$('#partner').serialize(),
            type: "POST",
            dataType:'json',
            success: function (d) {
                if(d){
                    if(d.error){
                        swal(d.msg, "", "warning");
                        return false;
                }else{
                        swal(d.msg, "", "success");
                        //window.location.href="/admin/news/list";
                        setTimeout("self.location=document.referrer;",1000);
                    }
                }
            }
        })

    }
</script>
